new Vue({
	el: "body",
	data: {
		current: false,
		username: "用户请登录",
		loading: false,
		user: {}
	},
	methods: {
		logOut: function() {
			AV.User.logOut();
			var currentUser = AV.User.current();
			if(currentUser) {
				this.current = true;
			} else {
				this.current = false;
				this.username = "用户请登录";
			}
		},
		login: function() {
			location.href = "../loginAndReg/login.html";
		},
		myOrder: function() {
			location.href = "../Order/order.html";
		},
		myAddress: function() {
			var currentUser = AV.User.current();
			if(currentUser) {
				this.current = true;
				location.href = "../address/address.html";
			} else {
				this.current = false;
				this.username = "用户请登录";
			}
		},
		price:function(){
			location.href="../Recharge/Recharge.html";
		},
		integral:function(){
			location.href="../integral/integral.html";
		}
	},
	created: function() {
		init();
		var currentUser = AV.User.current();
		if(currentUser) {
			this.current = true;
			this.username = currentUser.attributes.username;
			var userid = currentUser.id;
			var _this = this;
			var query = new AV.Query('_User'); //用户表
			query.get(userid).then(function(user) {
				console.log(user);
				_this.user =user.attributes;
			})
		} else {
			this.current = false;
		}
		this.loading = true;
	},
	beforeCompile: function() {
		this.loading = true;
	}
})